package com.hbase.mapreduce;

import java.io.IOException;
import java.util.List;

import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Table;

import com.google.common.collect.Lists;

public class InitData {

	static TableName hWorldTable=TableName.valueOf("word");
	static byte[] hWorldTableFamily="content".getBytes();
	static TableName hResultTable=TableName.valueOf("result");
	static byte[] hResultFamily="result".getBytes();
	
	public static void main(String[] args) throws IOException {
		//创建work表
		HBaseUtil.createTable(hWorldTable, hWorldTableFamily);
		//获取word表
		Table htable=HBaseUtil.getTable(hWorldTable);

		//创建测试数据
		List<Put> puts=Lists.newArrayList();
		Put put1=new Put("1".getBytes());
		put1.addColumn(hWorldTableFamily, null, "The Apache Hadoop software library is a framework".getBytes());
		
		Put put2=new Put("2".getBytes());
		put2.addColumn(hWorldTableFamily, null, "The common utilities that support the other Hadoop modules".getBytes());

		
		Put put3=new Put("3".getBytes());
		put3.addColumn(hWorldTableFamily, null, "Hadoop by reading the documentation".getBytes());

		Put put4=new Put("4".getBytes());
		put4.addColumn(hWorldTableFamily, null, "Hadoop from the release page".getBytes());

		Put put5=new Put("5".getBytes());
		put5.addColumn(hWorldTableFamily, null, "Hadoop on the mailing list".getBytes());

		puts.add(put1);
		puts.add(put2);
		puts.add(put3);
		puts.add(put4);
		puts.add(put5);
		
		//htable.mutateRow(rm);
		htable.put(puts);
		htable.close();
		
		//创建结果表
		HBaseUtil.createTable(hResultTable, hResultFamily);
		HBaseUtil.close();
	}

	
}
